package com.zzh.ideas.starter.config;

import com.zzh.ideas.starter.service.StarterService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

import javax.annotation.Resource;

/**
 * description： <br>
 * createTime: 2019/7/129:39 <br>
 *
 * @author zzh
 */
//@Configuration
@ConditionalOnClass(StarterService.class)
@EnableConfigurationProperties(StarterServiceProperties.class)
public class StarterAutoConfigure {

    @Resource
    private StarterServiceProperties properties;

    @Bean
    @ConditionalOnMissingBean
    @ConditionalOnProperty(prefix = "zzh.service", value = "enabled", havingValue = "true")
    StarterService starterService (){
        System.out.println("-------------------------------------------------------------------------------------@Bean");
        return new StarterService(properties.getConfig());
    }

}
